﻿@model HomePageViewModel
@using MyBlog.Common;
@{
    ViewBag.Title = "个人主页";
}
<div style="height:80px;background:#f7f7f7">
    <img class="layui-col-md2" style="width:60px;height:60px" src="~/images/@Model.Photo"/>
    <div class="layui-col-md10">
        <label style="margin:10px" class="layui-font-18">@Model.Name</label>
        <div style="margin:10px" class="layui-font-16">
            <label>总访问量：@Model.PageView</label>
            <label style="margin-left:5px">博客数量：@Model.BlogCount</label>
        </div>
    </div>
</div>
<div style="margin-top:2px">
    <ul class="layui-nav layui-bg-gray">
        <li class="layui-nav-item"><a id="all">所有博客</a></li>
        <li class="layui-nav-item"><a id="maxAccess">最多访问</a></li>
        <li class="layui-nav-item"><a id="latestRelease">最新发布</a></li>

    </ul>
    <hr>

    <div class="flow-demo" id="ID-flow-demo"></div>
</div>


<script>

    layui.use(function () {
        var flow = layui.flow;
        // 流加载实例

        window.uploadData = function (type) {
            flow.load({
                elem: '#ID-flow-demo', // 流加载容器
                scrollElem: '#ID-flow-demo', // 滚动条所在元素，一般不用填，此处只是演示需要。
                done: function (page, next) { // 执行下一页的回调
                    // 模拟数据插入
                    setTimeout(function () {
                        var lis = [];
                        $.post('/blog/list', { page: page, userid: @Model.UserId, type: type }, function (res) {

                            var pagingData = res.data
                            lis.push(pagingData.dataList[0]);

                            //pages为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多
                            next(lis.join(''), page < pagingData.recordCount); //假设总页数为 10
                        });
                    });
                }
            });
        }
    });
    $("#maxAccess").click(function () {
        uploadData(2);
    });
    function tabClick(type) {
        uploadData(type);
    }
    $(function () {
        //uploadData(1);

    });
    
</script>